package define

// 一级分类定义
var AlarmFirstClass = map[int]string{
	1: "自动驾驶",
	2: "业务告警",
	3: "嵌入式告警",
}

// 二级分类定义
var AlarmSecondClass = map[int]map[int]string{
	1: {
		1: "停止移动",
		2: "风险告警",
	},
	2: {
		2: "风险告警",
	},
}

type AlarmDescription struct {
	Name          string // 告警名称
	Visible       bool   // 前端是否显示
	FirstClass    int    // 一级分类
	SecondClass   int    // 二级分类
	MergeType     int    // 可合并的告警类型
	MergeTimeout  int    // 合并超时时间,单位s
	MinInterval   int    // 最小间隔，单位s，用来告警限流
	MaxTimesOfDay int    // 一天告警的最大次数
	Detail        string // 告警详情
}

// 告警类型
var AlarmType = map[int]AlarmDescription{
	0x00: {Name: "超声告警", Visible: true, FirstClass: 1, SecondClass: 1},
	0x01: {Name: "碰撞告警", Visible: true, FirstClass: 1, SecondClass: 1, MaxTimesOfDay: 2, MinInterval: 600},
	0x04: {Name: "停止移动", Visible: true, FirstClass: 1, SecondClass: 1},
	0x05: {Name: "急停告警", Visible: true, FirstClass: 1, SecondClass: 1},
	0x06: {Name: "算法围困", Visible: true, FirstClass: 1, SecondClass: 1},
	0x07: {Name: "回充失败", FirstClass: 1, SecondClass: 2},
	0x08: {Name: "嵌入式", FirstClass: 1, SecondClass: 2},
	0x09: {Name: "待机告警", FirstClass: 1, SecondClass: 1},
	0x0A: {Name: "低电告警", FirstClass: 1, SecondClass: 2},
	0x0B: {Name: "电梯告警", FirstClass: 1, SecondClass: 2},
	0x0C: {Name: "雷达遮挡", FirstClass: 1, SecondClass: 1},
	0x0D: {Name: "强制转动", FirstClass: 1, SecondClass: 1},
	0x0E: {Name: "定位丢失", FirstClass: 1, SecondClass: 2},
	0x0F: {Name: "单线雷达", FirstClass: 1, SecondClass: 1},
	0x10: {Name: "多线雷达", FirstClass: 1, SecondClass: 1},
	0x11: {Name: "虚拟墙", FirstClass: 1, SecondClass: 1},
	0x12: {Name: "RGBD", FirstClass: 1, SecondClass: 1},
	0x13: {Name: "命令暂停", FirstClass: 1, SecondClass: 1},
	0x14: {Name: "识别人体", FirstClass: 1, SecondClass: 1},
	0x15: {Name: "售卖暂停", FirstClass: 1, SecondClass: 1, Detail: "97售卖致机器停止移动超过十分钟"},
	0x16: {Name: "无定位", FirstClass: 1, SecondClass: 1, Detail: "请人工重定位恢复"},
	0x17: {Name: "断充告警", FirstClass: 1, SecondClass: 2},
	0x18: {Name: "急停未复位", FirstClass: 1, SecondClass: 1},
	0x19: {Name: "轮机失控", FirstClass: 1, SecondClass: 1},
	0x1A: {Name: "轮子打滑", FirstClass: 1, SecondClass: 1},
	0x1B: {Name: "工控机内存不足", FirstClass: 1, SecondClass: 1},
	0x1C: {Name: "未检测到充电桩二维码", FirstClass: 1, SecondClass: 1},
	0x1D: {Name: "与充电桩通信失败", FirstClass: 1, SecondClass: 1},
	0x1E: {Name: "充电桩未放电", FirstClass: 1, SecondClass: 1},
	0x1F: {Name: "充电时电源无电流输入", FirstClass: 1, SecondClass: 1},
	0x20: {Name: "回充摄像头异常", FirstClass: 1, SecondClass: 1},
	0x21: {Name: "上位机异常退出", FirstClass: 1, SecondClass: 1},
	0x22: {Name: "系统磁盘不足", FirstClass: 1, SecondClass: 1},
	0x23: {Name: "任务启动失败", FirstClass: 1, SecondClass: 1},
	0x24: {Name: "触发定位安全保护,已停止移动", FirstClass: 1, SecondClass: 1},
	0x25: {Name: "硬件设备异常", FirstClass: 1, SecondClass: 1},
	0x26: {Name: "回充过程异常", FirstClass: 1, SecondClass: 1},
	0x27: {Name: "CPU占用过高", FirstClass: 1, SecondClass: 1},
	0x28: {Name: "Disk2异常", FirstClass: 1, SecondClass: 1},
	0x29: {Name: "工控机时间同步异常", FirstClass: 1, SecondClass: 1},
	0x2A: {Name: "任务时嵌入式充电中", FirstClass: 1, SecondClass: 1},
	//1xxx 售卖相关
	1001: {Name: "退款", FirstClass: 2, SecondClass: 2},
	1002: {Name: "低库存", FirstClass: 2, SecondClass: 2, Detail: "库存不足，存量低于25%，请及时安排补货"},
	1003: {Name: "商品加载失败", FirstClass: 2, SecondClass: 2, Detail: "15秒内未获取到商品信息，请检查网络情况"},
	1004: {Name: "关舱超时", FirstClass: 2, SecondClass: 2, Detail: "关舱时间超过30s，请排查：货盘中商品是否取出、货盘中是否存在异物、舱门是否被遮挡"},
	1005: {Name: "初始化错误", FirstClass: 2, SecondClass: 2, Detail: "请检查货盘摄像头是否正常连接"},
	1006: {Name: "货门未关闭", FirstClass: 2, SecondClass: 2},
	1007: {Name: "停止售卖", FirstClass: 2, SecondClass: 2},
	1008: {Name: "97黑屏", FirstClass: 2, SecondClass: 2, Detail: "售卖面板黑屏请确认机器状态"},
	1009: {Name: "大内存告警[研发关注]", FirstClass: 2, SecondClass: 2, Detail: "研发需要关注，不涉及运营"},
	1010: {Name: "97本地存储不足", FirstClass: 2, SecondClass: 2, Detail: "检查本地存储空间占用情况并清理"},
	1201: {Name: "创单失败", FirstClass: 2, SecondClass: 2},
	//2xxx 设备相关 - 未来会变更
	2001: {Name: "95离线", FirstClass: 1, SecondClass: 1, MergeType: 2010, MergeTimeout: 60, MinInterval: 0},
	2002: {Name: "97离线", FirstClass: 1, SecondClass: 1, MergeType: 2010, MergeTimeout: 60, MinInterval: 0},
	2003: {Name: "98离线", FirstClass: 1, SecondClass: 1, MergeType: 2010, MergeTimeout: 60, MinInterval: 0},
	2004: {Name: "95开机失败", FirstClass: 1, SecondClass: 1, MergeType: 2011, MergeTimeout: 60},
	2005: {Name: "97开机失败", FirstClass: 1, SecondClass: 1, MergeType: 2011, MergeTimeout: 60},
	2006: {Name: "98开机失败", FirstClass: 1, SecondClass: 1, MergeType: 2011, MergeTimeout: 60},
	2007: {Name: "95关机失败", FirstClass: 1, SecondClass: 1, MergeType: 2012, MergeTimeout: 60},
	2008: {Name: "97关机失败", FirstClass: 1, SecondClass: 1, MergeType: 2012, MergeTimeout: 60},
	2009: {Name: "98关机失败", FirstClass: 1, SecondClass: 1, MergeType: 2012, MergeTimeout: 60},
	2010: {Name: "整机离线", FirstClass: 1, SecondClass: 1},
	2011: {Name: "开机失败", FirstClass: 1, SecondClass: 1},
	2012: {Name: "关机失败", FirstClass: 1, SecondClass: 1},
	//3xxx 广告相关
	3001: {Name: "广告投放异常", FirstClass: 1, SecondClass: 1},
	3002: {Name: "98本地存储不足", FirstClass: 1, SecondClass: 1},
	3003: {Name: "广告新订单", FirstClass: 1, SecondClass: 1},
}

// 告警类型对应的模板
var AlarmTypeTpl = map[int]int{
	0:    1,
	1:    1,
	4:    1,
	5:    1,
	6:    1,
	7:    2,
	9:    2,
	10:   3,
	11:   2,
	12:   1,
	13:   2,
	14:   2,
	15:   1,
	16:   1,
	17:   1,
	18:   1,
	19:   1,
	20:   1,
	21:   1,
	22:   1,
	23:   2,
	24:   1,
	28:   1,
	29:   1,
	30:   1,
	31:   1,
	32:   1,
	50:   2,
	51:   2,
	52:   2,
	100:  2,
	1001: 2,
	1002: 4,
	1003: 2,
	1004: 2,
	1005: 2,
	1008: 2,
}

// 告警模板
var AlarmTpl = map[int]string{
	1: "<{first_class}>告警，<{second_class}>通知：机器人{robot_id}，类型：{device_type}，于{created_at}触发{alarm_type}，达{duration}分钟，使用地图为{map}，请及时处理。",
	2: "<{first_class}>告警，<{second_class}>通知：机器人{robot_id}，类型：{device_type}，于{created_at}触发{alarm_type}，使用地图为{map}，请及时处理。",
	3: "<{first_class}>告警，<{second_class}>通知：机器人{robot_id}，类型：{device_type}，于{created_at}触发{alarm_type}，当前电量为{battery}，使用地图为{map}，请及时处理。",
	4: "<{first_class}>告警，<{second_class}>通知：机器人{robot_id}，类型：{device_type}，库存不足，请及时处理。",
}

// 告警模板-精简版
var AlarmTplLite = map[int]string{
	1: "{alarm_type}",
	2: "{alarm_type}",
	3: "当前电量{battery}",
	4: "库存不足",
}

// 通知类型
var NotifyType = map[int]string{
	1: "微信",
	2: "邮件",
}
